package com.xxh.food.controller;

import com.xxh.food.common.Result;

import com.xxh.food.utils.FileUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ClassUtils;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping(value = "/file")
@Api(tags = "文件模块接口")
public class FileController {


    @ApiOperation(value = "上传图片")
    @PostMapping(value = "/img/upload")
    public Result<?> imagepload(@RequestParam(value = "imgFile",required = true) MultipartFile imgFile) throws IOException {

        String realPath = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\img\\";
        System.out.println(realPath);
        String imgName = FileUtils.saveFile(imgFile, realPath);
        return Result.success(imgName);
    }




}
